from kafka import KafkaProducer
import time

if __name__ == '__main__':
    producer = KafkaProducer(bootstrap_servers="master:9092,node1:9092,node2:9092")

    with open("../data/students.txt", encoding="utf-8") as file:
        lines = file.readlines()
        for line in lines:
            producer.send(topic="bigdata", value=line.encode("utf8"))
            producer.flush()
            time.sleep(0.5)
    producer.close()
